/* manydice.c -- multiple dice rolls                    */
/* compile with diceroll.c                              */
#include <stdio.h>
#include <stdlib.h>              /* for library srand() */
#include <time.h>                /* for time()          */
#include <ctype.h>
#include <string.h>
#include "diceroll.h"            /* for roll_n_dice()   */
/* and for roll_count  */
#include <mylib.h>


int main(void) {
    int size;
    int dice;
    int side;
    printf("Enter the number of sets; enter 0 to stop:");
    while (scanf("%d", &size) == 1 && size > 0) {
        printf("How many sides and how many dice?");
        while (scanf("%d %d", &side, &dice) != 2 || side < 1||dice<1) {
            puts("the input is wong,try again.");
            printf("How many sides and how many dice?");
        }
        printf("Here are %d sets of %d %d-sides throws.\n", side, dice, side);
        for (int i = 0; i < size; ++i) {
            int val = 0;
            for (int j = 0; j < dice; ++j) {
                val += rand() % side + 1;
            }
            printf("%d ", val);
        }
        puts("");
        printf("How many sets?Enter 0 to stop:");
    }


    return 0;
}
